<template>
	<view class="containers">
		<scroll-view 
		          :scroll-top="scrollTop"
		          scroll-y="true"
		          class="scroll-Y"
				  style="height:90vh;">
			<view class="center u-m-t-30">
				<view class="view-check">
					<view class="check">
						<view class="check-item" :class="{'active':active}" @click="handleClickCheck(true)">我的观点</view>
						<view class="check-item" :class="{'active':!active}" @click="handleClickCheck(false)">内容举报</view>
					</view>
				</view>
				<u-form :model="model" :rules="rules" ref="uForm" :errorType="errorType">
					<view class="form " v-show="active">
						<view class="u-flex u-row-center topone u-p-b-30">
							很高兴我们完成合作，请发表您的观点，您的好评
							将有利于我们更有信心
						</view>
						<view class="u-flex u-row-center myview">
							我的观点
						</view>
						<view class="u-flex u-row-center star u-m-t-20 u-p-b-20">
							<u-rate v-model="model.score" :count="count" :active-color="activeColor" :inaction-color="inactiveColor" :size="60" :disabled="disabled"></u-rate>
						</view>

						<u-form-item class="group" label-width="200" :border-bottom="true" :label-position="labelPosition" label="打赏金额">
							<u-input v-model="model.rewardAmount" :border="border" placeholder="请输入金额" type="text" input-align="right"></u-input>
							<text class="u-p-l-20">智汇币</text>
						</u-form-item>

						<u-form-item class="zwpj u-m-t-20" :border-bottom="false" :label-position="labelPosition">
							<u-input type="textarea" v-model="model.comment" :border="border" placeholder="请输入工作心得" />
						</u-form-item>
					</view>

					<view class="form formtwo" v-show="!active">
						<u-form-item class="group" label-width="200" :border-bottom="true" :label-position="labelPosition" label="举报内容">
							<view class="value" style="width:100%;text-align: right;" @click="showReport = true">{{model.report || "请选择"}}</view>
							<u-picker mode="selector" @confirm="confirm" :range="listReport" v-model="showReport"></u-picker>
						</u-form-item>
						<view class="u-flex u-row-start others u-m-t-30">
							<image src="../../static/img/shuoming.png"></image>
							<view class="u-m-l-20">其他说明</view>
						</view>
						<u-form-item class="zwpj u-m-t-20" :border-bottom="false" :label-position="labelPosition">
							<u-input type="textarea" v-model="model.otherRemark" :border="border" placeholder="请输入其他说明" />
						</u-form-item>
						<view class="u-flex u-row-start others u-m-t-30">
							<image src="../../static/img/shuoming.png"></image>
							<view class="u-m-l-20">提交证据</view>
						</view>
						<u-form-item class="" :border-bottom="false" :label-position="labelPosition" label-width="150">
							<u-upload ref="uUpload"  @on-uploaded="onUploaded" :action="action" :auto-upload="autoUpload" :file-list="fileList" :show-progress="showProgress" :max-count="maxCount" :site="baseUrl">
							</u-upload>
						</u-form-item>
					</view>
					<u-button class="button" @click="onClick">提交</u-button>
				</u-form>

			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		name: "m-viewpoint",
		props: {
			datas: Array, //数据
			curror: Number
		},
		data() {
			let that = this;
			return {
				fileList: [],
				showUploadList: true,
				customBtn: false,
				autoUpload: true,
				showProgress: false,
				deletable: true,
				customStyle: false,
				maxCount: 9,
				lists: [], // 组件内部的文件列表
				filePaths:'', // 文件路径
				fileNames:'', // 文件名称
				action:this.$apis.uploadFile,
				baseUrl:this.$mConfig.baseUrl,
				activeColor: '#FF9900',
				inactiveColor: '#FFE2CF',
				disabled: false,
				count: 5,
				customIcon: false,
				plain: false,
				value: 4,
				active: true,
				model: {
					"businessId": '',
					"comment": "",
					"createTime": "",
					"images": [],
					"otherRemark": "",
					"report": "",
					"rewardAmount": '',
					"score": 5,
					"type": 0,
				},
				rules: [],
				errorType: ['toast'],
				listReport: ['欺诈', '虚假', '工程问题', '其他'],
				showReport: false,
				border: false,
				labelPosition: 'left',
				scrollTop: 0,
				old: {
					scrollTop: 0
				},
				followLogo: this.$mAssetsPath.followLogo,
				bgColor: this.$u.color.bgColor,
				marginTop: 30,
				marginBottom: 30,
			};
		},
		mounted() {},
		onShow() {},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		created: function() {
			var that = this;
			let list = that.datas;
			this.list = list;
			console.log(this.curror);
			this.active = this.curror?false:true;
		},
		methods: {
			onUploaded(lists) {
				 var filePaths = [],fileNames = [];
				 for(let i in lists){
				 	console.log('data',lists[i].response);
				 	if(lists[i].response.code == 200){
				 		filePaths.push(lists[i].response.message);
				 	}
				 }		
				 //this.filePaths = filePaths.join(',');
				 this.model.images = filePaths;
			},
			handleClickCheck(e) {
				this.active = e
			},
			confirm(e) {
				var itemKey = e[0];
				this.model.report = this.listReport[itemKey];
			},
			onClick() {
				this.$emit('click', {
					model: this.model
				})
			},
			scroll(){}
		}

	}
</script>

<style scoped lang="scss">
	page {
		background: #f4f4f4;
	}

	.others image {
		width: 29rpx;
		height: 29rpx;
	}

	.button {
		width: 602rpx;
		margin: 132rpx auto 70rpx auto;
		background: #ab61ff;
		border-radius: 40rpx;
		border: 0;
		color: #fff;

		&.u-hairline-border:after {
			border: 0;
		}
	}

	.toptwo {

		font-size: 36rpx;

		color: #4B9CFF;
	}

	.zwpj {
		width: 100%;
		margin: 0 auto;
		height: 260rpx;
		background-color: #F5F5F9;
		font-size: 30rpx;
		color: #F5F5F9;
		border-radius: 10rpx;
		line-height: 44rpx;
	}

	.topone {

		color: #FF9900;

		font-size: 28rpx;
	}

	.riqi {
		padding: 4rpx;

		color: #4B9CFF;
		// opacity: 0.1;
		border-radius: 6rpx;
		background: #b9cce2;
	}

	.zhihui image {
		width: 27rpx;
		height: 27rpx;
	}

	.myview {

		color: #0D1D36;
		font-size: 36rpx;
	}

	.star image {
		width: 48rpx;
		height: 48rpx;
		margin-right: 30rpx;

	}

	.container {
		position: relative;

		.top {
			position: absolute;
			top: 0;
			width: 100%;
			height: 370upx;
			background: linear-gradient(0deg, #AC62FF, #DF62FF);
		}

		.qiye {
			position: relative;
		}

		.center {
			width: 690rpx;
			margin-bottom: 200rpx;
			z-index: 1;
			margin-left: 30rpx;
			position: relative;
			overflow: hidden;

			.form {
				width: 100%;
				height: 680rpx;
				background-color: #fff;
				border-radius: 20rpx;
				padding: 32rpx 30rpx;
				margin-top: 57rpx;
				// border: 1px solid;

				.zhaopin {

					font-size: 36rpx;
					color: #0E1E36;
				}

				.zhaopintwo {
					font-size: 28rpx;

					color: #888D99;
				}
			}

			.formtwo {
				height: auto;
			}

			.qiye {
				width: 100%;
				height: 90rpx;
				background: #FFFFFF;
				border-radius: 20rpx 20rpx 0px 0px;

				.list {
					.item {
						display: flex;
						align-items: center;
						padding: 0 24rpx;
						justify-content: space-between;
					}
				}
			}
		}
	}

	.view-check {
		background-color: #fff;
		height: 110rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		// border-bottom: #f4f4f4 solid 1rpx;

		.check {
			width: 460rpx;
			height: 64rpx;
			display: flex;
			background-color: #F0F0F0;
			border-radius: 32rpx;

			.check-item {
				width: 230rpx;
				text-align: center;
				line-height: 64rpx;
				border-radius: 32rpx;
				color: #0E1E36;
			}

			.active {
				color: #fff;
				background-color: #AB62FF;
			}
		}
	}
</style>
